package datacrawl.test;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;  
  
import org.xml.sax.SAXException;  


public class HuiCongTest2 {  
  
	private static String jsPath = System.getProperty("user.dir")+File.separator+"huicong.js";
    public static void main(String[] args) throws IOException, SAXException {  
    	
    
    	String html = getParseredHtml2( "http://gzyuanzhi.b2b.hc360.com/" );
		System.out.println("html: "+html);
    }  
    //网上的另一个例子
    public static String getParseredHtml2(String url) throws IOException
    {
    	Runtime rt = Runtime.getRuntime();     
        Process p = rt.exec("phantomjs.exe "+jsPath+" "+url);//这里我的codes.js是保存在c盘下面的phantomjs目录     
        InputStream is = p.getInputStream();     
        BufferedReader br = new BufferedReader(new InputStreamReader(is));     
        StringBuffer sbf = new StringBuffer();     
        String tmp = "";     
        while((tmp = br.readLine())!=null){     
            sbf.append(tmp);     
        }       
        return sbf.toString();   
    }
  
}  